#include "database.h"

int main(int argc, char const *argv[])
{
    sqlite3 *pDB = NULL; // 数据库的指针
    pDB = openSqlite3("abc.db");
    if (pDB == NULL)
    {
        printf("打开或者创建数据库失败\n");
        return -1;
    }
    GAME_AC as;
    strcpy(as.name, "lisi");
    strcpy(as.game_name, "使命召唤手游");
    strcpy(as.items, "M13-黑耀星辰，Krig 6-冰霜巨龙，Oden-神圣惩戒，EM2-苍穹，Kilo 141-暗夜奏鸣曲； 典藏武器：AK47-炎舞慕雪·典藏");
    as.price = 1400;
    char szSql[512];
    // 把用户名和密码插入到数据表中
    sprintf(szSql, "INSERT INTO game_accounts (username, game_name, items, price)\
               VALUES ( '%s', '%s' ,'%s', '%d')",
            as.name, as.game_name, as.items, as.price);
    char *msg_1 = NULL;
    sqlite3_exec(pDB, szSql, 0, 0, &msg_1);
    // 如果msg不为空，说明有错误信息
    if (msg_1 != NULL)
    {
        printf("注册失败，错误的原因是：%s", msg_1);
    }
    return 0;
}
